using System;
using System.Drawing;
using System.Windows.Forms;
using Belmost4PDA.Logic;

namespace Belmost4PDA.Logic
{
    public class HintCombo: ComboBox, IReadOnly
    { 
        private bool _RO=false;
        private readonly Label lb;
        // public event EventHandler OnHint;
        public HintCombo()
        { 
            lb=new Label();
            lb.Name = "LB";
            lb.Text = "";
            
        }

        protected override void OnGotFocus(EventArgs e)
        {
            if(Parent!=null&&!Parent.Controls.Contains(lb)) Parent.Controls.Add(lb);
            base.OnGotFocus(e);
            if (ROnly)
            {
                lb.Location = new Point(Location.X, Location.Y); lb.Focus();
            }
           
        }
        protected override void OnPaint(PaintEventArgs e)
        {
            if (ROnly)
                base.OnPaint(e);
        }
        #region IReadOnly Members

        public bool ROnly
        {
            get
            {
                return _RO;
            }
            set
            {
                _RO=value;
                if (_RO) BackColor = SystemColors.Control;
                else BackColor = Color.White;
                if (_RO) lb.Focus();
            }
        }

        #endregion
    }
}